package com.ciwong.epaper.modules.epaper.bean;

import com.ciwong.mobilelib.bean.BaseBean;
import com.google.gson.Gson;

import java.lang.reflect.Type;
import java.util.List;

/**
 * Created by neo on 2016/8/19.
 */
public class TempWorkAnswers extends BaseBean {

//    private static final long serialVersionUID = 3189460112478030610L;
    /**
     * 资源版本ID
     */
    private String versionId;

    /**
     * 得分
     */
    private float score;

    /**
     * 对错判断(0:未批改 1:对 2:错 3:半对 4:未知)
     */
    private int assess = Assess.ASSESS_NO_CORRECT;

    /**
     * 答案集合
     */
    private List<OnlineAnswerInfo> answers;

    public String getVersionId()
    {
        return versionId;
    }

    public void setVersionId(String versionId)
    {
        this.versionId = versionId;
    }

    public float getScore()
    {
        return score;
    }

    public void setScore(long score)
    {
        this.score = score;
    }

    public int getAssess()
    {
        return assess;
    }

    public void setAssess(int assess)
    {
        this.assess = assess;
    }

    public List<OnlineAnswerInfo> getAnswers()
    {
        return answers;
    }

    public void setAnswers(List<OnlineAnswerInfo> answers)
    {
        this.answers = answers;
    }

    /**
     * 是否正确常量类
     *
     * @author bin
     */
    public static class Assess
    {
        /**
         * 未批改
         */
        public static final int ASSESS_NO_CORRECT = 0;

        /**
         * 对
         */
        public static final int ASSESS_CORRECT = 1;

        /**
         * 错
         */
        public static final int ASSESS_ERROR = 2;

        /**
         * 半对
         */
        public static final int ASSESS_HALF_CORRECT = 3;

        /**
         * 未知
         */
        public static final int ASSESS_UNKNOWN = 4;
    }

    @Override
    public String toString()
    {
        return new Gson().toJson(this);
    }

    public String toJson(Class<Answer> clazz)
    {
        Gson gson = new Gson();
        Type objectType = getType(Answer.class, clazz);
        return gson.toJson(this, objectType);
    }

    @Override
    public boolean equals(Object o)
    {
        return getVersionId() != null
                && getVersionId().equals(((WorkAnswers) o).getVersionId());
    }
}
